﻿// <copyright file="ThisAddIn.cs" company="Microsoft Corporation">
// Copyright (c) 2008 All Right Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2008-10-10</date>
// <summary>Add In component</summary>

namespace WordFlowDocumentCreator
{
    using System;

    /// <summary>
    /// Add in class
    /// </summary>
    public partial class ThisAddIn
    {
        #region Fields
        /// <summary>
        /// the ribbon UI
        /// </summary>
        private Ribbon1 ribbon;

        #endregion

        #region Overrides
         /// <summary>
         /// if the ribbon manager is requested, return the custom ribbon manager
         /// </summary>
         /// <param name="serviceGuid">the service GUID</param>
         /// <returns>the custom ribbon manager</returns>
        protected override object RequestService(Guid serviceGuid)
        {
            object service = base.RequestService(serviceGuid);

            return service;

            ////Microsoft.Office.Tools.Ribbon.RibbonManager ribbonManager = service as Microsoft.Office.Tools.Ribbon.RibbonManager;

            ////if (ribbonManager != null)
            ////{
            ////    if (this.customRibbonManager == null)
            ////    {
            ////        this.customRibbonManager = new CustomRibbonManager(ribbonManager);
            ////    }

            ////    service = this.customRibbonManager;
            ////}

            ////return service;
        }

        #endregion

        /// <summary>
        /// Create a new Ribbon Extensibility object with the Ribbon1 class.
        /// </summary>
        /// <returns>a new instance of the Ribbon1 class</returns>
        protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
        {
            this.ribbon = new Ribbon1();

            return this.ribbon;
        }

        /// <summary>
        /// Add-in startup
        /// </summary>
        /// <param name="sender">this add in</param>
        /// <param name="e">the event arguments</param>
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
        }

        /// <summary>
        /// add-in shut down event handler
        /// </summary>
        /// <param name="sender">the add-in</param>
        /// <param name="e">event arguments</param>
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
            this.ribbon.SaveOptions();
        }

        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
        
        #endregion
    }
}
